// run: $exec < input
#include <iostream>
#include <algorithm>
#include <string>

int const l = 26;
int const maxn = 300007;
int next[maxn][l + 4];
long long res[l + 4];
std::string s;

int main()
{
	std::ios::sync_with_stdio(false);
	std::cin >> s;
	int n = s.size();
	for (int i = 0; i < l; i++) {
		next[n][i] = n;
		for (int j = n - 1; j >= 0; j--)
			if (s[j] == 'a' + i) next[j][i] = j;
			else next[j][i] = next[j + 1][i];
	}
	for (int i = 0; i < n; i++) {
		next[i][l] = n;
		std::sort(next[i], next[i] + l);
		for (int j = 0; j < l; j++)
			res[j + 1] += next[i][j + 1] - next[i][j];
	}
	int ds = 0;
	for (int i = 0; i < l; i++)
		if (next[0][i] != n) ds += 1;
	std::cout << ds << "\n";
	for (int i = 0; i < ds; i++)
		std::cout << res[i + 1] << "\n";
}

